package com.maochd.cloud.excel.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.maochd.cloud.excel.condition.ExportQueryCondition;
import com.maochd.cloud.excel.entity.ExportRecord;
import com.maochd.cloud.excel.mapper.ExportRecordMapper;
import com.maochd.cloud.excel.service.ExportRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class ExportRecordServiceImpl extends ServiceImpl<ExportRecordMapper, ExportRecord> implements ExportRecordService {

    @Override
    public Page<ExportRecord> listByCondition(ExportQueryCondition condition) {
        return this.page(condition.orderWithPage(), Wrappers.<ExportRecord>lambdaQuery()
                .eq(Objects.nonNull(condition.getExportType()), ExportRecord::getExportType, condition.getExportType())
                .eq(Objects.nonNull(condition.getUserId()), ExportRecord::getUserId, condition.getUserId()));
    }
}
